/**
 * 
 */
var boardid = Ext.util.Cookies.get('boardid');
Ext.util.Cookies.set('boardid', null);
var title, publisher, content;

function init() {
	Ext.Ajax.request({
		url : 'boardAction!getById.action?boardid=' + boardid,
		success : function(response) {
			var responseText = response.responseText;
			responseText = Ext.JSON.decode(responseText);
			var board = responseText.board;
			if (board != null) {
				title = board.title;
				publishername = board.publishername;
				content = board.content;
				var _publishtime = board.publishtime;
				if (_publishtime != null) {
					var dates = _publishtime.substr(0, 10).split("-");
					var publishtime = new Date(dates[0], dates[1] - 1,
							dates[2], _publishtime.substr(11, 2), _publishtime
									.substr(14, 2));
					publishtime = Ext.util.Format.date(publishtime,
							'Y年m月d日 H:i:s');
				} else {
					publishtime = "尚未发布";
				}

				// if (board.attach != null) {
				// attachname = '<a target="_blank"
				// href="boardAction!down.action?boardid='
				// + board.id
				// + '&fileName='
				// + board.attachname
				// + '">'
				// + board.attachname + '</a>';
				// } else {
				// attachname = "无";
				// }
				Ext.getCmp('mypanel').body
						.update('<div align="center"><font size="5"><b>'
								+ title
								+ '</b></font><br><br><div align="right"><font size="3">'
								+ '发布时间：'
								+ publishtime
								+ '</font><br><br></div></div><div align="center">'
								+ '<div/><br><div align="center"><div align="left">'
								+ content + '</div></div>'
								+ '<br><br><br><div align="center">'
								// + '<div align="right">附件下载：' + attachname
								// + '</div>'
								+ '</div>');
			}
			// alert(document.getElementsByTagName("embed")[0].outerHTML);
		},
		failure : function(response) {
			alert("失败!");
		}
	});
}

Ext.onReady(function() {
			Ext.create('Ext.container.Viewport', {
						layout : 'fit',
						items : [{
							id : 'mypanel',
							autoScroll : true,
							bodyPadding : '10px 100px 10px 100px',
							xtype : 'panel',
							border : false,
							layout : 'fit',
							buttons : [{
								text : '关闭',
								id : 'closeBtn',
								handler : function() {
									// if (role == 'quxian') {
									// window.top.Utils.activePage("28");
									// window.top.Utils.getTabWindow("28");
									//
									// } else {
									// window.top.Utils.activePage("19");
									// window.top.Utils.getTabWindow("19");
									// }
									window.top.Utils.closePage('boardQuery'
											+ boardid);
								}
							}],
							buttonAlign : 'center'
						}]
					});
			init();
		});